package com.renshengjiwu.web.dto;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by xuzhike on 2016/1/16.
 */
public class ServerInfo {
    private String servletContextPath;
    private String realPath;
    private String servletPath;
    private String serverName;
    private String serverPort;
    private String contextPath;
    private String localAddr;
    private String localPort;
    private String remoteAddr;
    private String remoteHost;
    private String remotePort;
    private String requestedSessionId;
    private String requestURI;

    public String getServletContextPath() {
        return servletContextPath;
    }

    public void setServletContextPath(String servletContextPath) {
        this.servletContextPath = servletContextPath;
    }

    public String getRealPath() {
        return realPath;
    }

    public void setRealPath(String realPath) {
        this.realPath = realPath;
    }

    public String getServletPath() {
        return servletPath;
    }

    public void setServletPath(String servletPath) {
        this.servletPath = servletPath;
    }

    public String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public String getServerPort() {
        return serverPort;
    }

    public void setServerPort(String serverPort) {
        this.serverPort = serverPort;
    }

    public String getContextPath() {
        return contextPath;
    }

    public void setContextPath(String contextPath) {
        this.contextPath = contextPath;
    }

    public String getLocalAddr() {
        return localAddr;
    }

    public void setLocalAddr(String localAddr) {
        this.localAddr = localAddr;
    }

    public String getLocalPort() {
        return localPort;
    }

    public void setLocalPort(String localPort) {
        this.localPort = localPort;
    }

    public String getRemoteAddr() {
        return remoteAddr;
    }

    public void setRemoteAddr(String remoteAddr) {
        this.remoteAddr = remoteAddr;
    }

    public String getRemoteHost() {
        return remoteHost;
    }

    public void setRemoteHost(String remoteHost) {
        this.remoteHost = remoteHost;
    }

    public String getRemotePort() {
        return remotePort;
    }

    public void setRemotePort(String remotePort) {
        this.remotePort = remotePort;
    }

    public String getRequestedSessionId() {
        return requestedSessionId;
    }

    public void setRequestedSessionId(String requestedSessionId) {
        this.requestedSessionId = requestedSessionId;
    }

    public String getRequestURI() {
        return requestURI;
    }

    public void setRequestURI(String requestURI) {
        this.requestURI = requestURI;
    }

    public static ServerInfo getServerJSON(HttpServletRequest request){
        ServerInfo serverInfo = new ServerInfo();
        serverInfo.setContextPath(request.getContextPath());
        serverInfo.setLocalAddr(request.getLocalAddr());
        serverInfo.setLocalPort(request.getLocalPort()+"");
//        serverInfo.setRealPath(request.get);
        serverInfo.setRemoteAddr(request.getRemoteAddr());
        serverInfo.setRemoteHost(request.getRemoteHost());
        serverInfo.setRemotePort(request.getRemotePort()+"");
        serverInfo.setRequestedSessionId(request.getRequestedSessionId());
        serverInfo.setRequestURI(request.getRequestURI());
        serverInfo.setLocalAddr(request.getLocalAddr());
        serverInfo.setServerName(request.getServerName());
        serverInfo.setServerPort(request.getServerPort()+"");
        serverInfo.setServletPath(request.getServletPath());
        serverInfo.setServletContextPath(request.getServletContext().getContextPath());
        return serverInfo;

    }
}
